
setTimeout(function(){
	$("#role_Name").focus();
	$("#role_Name").rules("add",{
		remote: {
			url : 'sys/roles/checkEditName?name='+$("#role_Name").val()+"&id="+getQueryString("id"),
			type: "get",
			dataType: "json", 
			dataFilter:function(data,type){
				return data=="false"?false:true;
			}
		}, 
		messages: {remote: "该角色名称已存在"}
		
	}); 
} , parseInt(Math.random() * 1000)); 

var app = angular.module('roleApp', []);



app.controller('roleController', function($scope, $http) {
	$scope.view=function(){
		$http.get(timestamp("sys/roles/get/"+getQueryString("id"))).success(function (response) {
			$scope.role = response.data;
		});
	}
	
	$scope.view();
	$scope.refreshData=function(){
		$scope.view();
	}
	
	$scope.roleSave=function(){
	   if($("#myForm").valid()){
		   $http.put('sys/roles/update/', $scope.role).success(function(){
			   redirectUrl("manage/role/","list.jsp");
           });
	   }
	}
	
	$scope.roleReset=function(){
		$scope.view();
	}
	
	$scope.roleCancle=function(){
		redirectUrl("manage/role/","list.jsp");
	}
});